import type {UpdatePwdForm, UserInfo} from "@/typings/auth";
import type {Ret} from "@/typings/api";

export const getUserInfo = async () => {
    return new Promise<Ret<UserInfo>>((resolve) => {
        const userInfo: UserInfo = {
            user: {
                id: 1,
                userName: "超级管理员",
                account: "admin",
                createTime: "2025-05-12 12:00:00",
                updateTime: "2025-05-12 12:00:00",
                isDel: false
            },
            permissions: [
                {
                    id: 1,
                    permissionTitle: "测试模块",
                    permissionIcon: "collection",
                    permissionIconColor: "#FF0000",
                    children: [
                        {
                            id: 2,
                            permissionTitle: "测试页面1",
                            permissionIcon: "catalog",
                            permissionIconColor: "#19deb0",
                            permissionPath: "/test1",
                            permissionName: "Test1",
                            permissionView: "test/1"
                        },
                        {
                            id: 3,
                            permissionTitle: "测试页面2",
                            permissionIcon: "catalog",
                            permissionIconColor: "#1999de",
                            permissionPath: "/test2",
                            permissionName: "Test2",
                            permissionView: "test/2"
                        },
                        {
                            id: 4,
                            permissionTitle: "测试页面3",
                            permissionIcon: "catalog",
                            permissionIconColor: "#196ede",
                            permissionPath: "/test3",
                            permissionName: "Test3",
                            permissionView: "test/3"
                        }
                    ]
                },{
                    id: 5,
                    permissionTitle: "系统设置",
                    permissionIcon: "system-setting",
                    permissionIconColor: "#d30606",
                    children: [
                        {
                            id: 6,
                            permissionTitle: "图标选择",
                            permissionIcon: "icon",
                            permissionIconColor: "#550ad7",
                            permissionPath: "/icon",
                            permissionName: "Icon",
                            permissionView: "sys/icon"
                        }
                    ]
                }
            ]
        }
        const ret = {
            code: 0,
            msg: "success",
            data: userInfo,
            time: new Date().toISOString(),
            success: true
        }
        resolve(ret);
    })
}

export const managerLogout = async () => {
    return new Promise<Ret<boolean>>((resolve) => {
        const ret = {
            code: 0,
            msg: "success",
            data: true,
            time: new Date().toISOString(),
            success: true
        }
        resolve(ret);
    })
}

export const managerUpdatePwd = async (updatePwdForm: UpdatePwdForm) => {
    console.log(updatePwdForm)
    return new Promise<Ret<boolean>>((resolve) => {
        const ret = {
            code: 0,
            msg: "success",
            data: true,
            time: new Date().toISOString(),
            success: true
        }
        resolve(ret);
    })
}